﻿<phone:PhoneApplicationPage
    x:Class="MobiSms.Wasun.Views.SerialCollectionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="clr-namespace:MobiSms.ViewModel;assembly=MobiSms.ViewModel"
    xmlns:UX="clr-namespace:MobiSms.UX;assembly=MobiSms.UX"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="False" d:DesignHeight="800" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:SerialCollectionViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush ImageSource="{Binding GlobalSettings.BackgroundImage}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}" />
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_SERIAL_MANAGEMENT}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <ListBox ItemsSource="{Binding ItemsOfSerial}" SelectedItem="{Binding SelectedSerial, Mode=TwoWay}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Button Tag="{Binding Guid}" Click="GotoDetailsView">
                                        <Button.Style>
                                            <Style TargetType="Button">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="Button">
                                                            <Grid Margin="0,0,0,24">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition/>
                                                                    <ColumnDefinition Width="auto"/>
                                                                </Grid.ColumnDefinitions>
                                                                <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                                                                           Text="{Binding SerialNumber}" />
                                                                <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                                                                           Text="{Binding Balance}" 
                                                                           Grid.Column="1" 
                                                                           Foreground="{StaticResource PhoneAccentBrush}"/>
                                                            </Grid>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </Button.Style>
                                    </Button>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
            <StackPanel Grid.Column="1" VerticalAlignment="Bottom">
                <UX:UXPathButton IconPath="{StaticResource PATH_ICON_REFRESH}" 
                                 Command="{Binding BalanceCommand}"
                                 Margin="12,0,12,12"/>
                <UX:UXPathButton IconPath="{StaticResource PATH_ICON_DELETE}" 
                                 Padding="13" 
                                 Margin="12,0,12,12" 
                                 Visibility="Collapsed"
                                 Command="{Binding DeleteCommand, Mode=OneWay}"/>
                <UX:UXPathButton IconPath="{StaticResource PATH_ICON_CLOSE}" 
                                 Padding="14" 
                                 Angle="45" 
                                 Margin="12,0,12,12"
                                 Uri="/Views/SerialAddView.xaml"/>
                <UX:UXPathButton IconPath="{StaticResource PATH_ICON_INVENTORY}" 
                                 Angle="0" 
                                 Padding="10"
                                 Margin="12,0,12,12"
                                 Uri="/Views/SerialRegisterView.xaml"/>
            </StackPanel>

        </Grid>

        <Grid Background="{StaticResource PhoneSubtleBrush}" Grid.RowSpan="2" Visibility="{Binding Path=Processing, Converter={StaticResource BooleanToVisibilityConverter}}">
            <ProgressBar IsIndeterminate="True"/>
        </Grid>

    </Grid>

</phone:PhoneApplicationPage>